#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <algorithm>

using namespace std;

void recursive(int i, vector<vector<int> >& subsets, const vector<int>& S, vector<int>& subset)
{
	if (i == S.size())
	{
		subsets.push_back(subset);
	}
	else
	{
		recursive(i + 1, subsets, S, subset);
		subset.push_back(S[i]);
		recursive(i + 1, subsets, S, subset);
		subset.pop_back();
	}
}

vector<vector<int> > subsets(vector<int>& S) {
	vector<vector<int> > ans;
	if (S.empty())
	{
		return ans;
	}

	sort(S.begin(), S.end());

	vector<int> subset;
	recursive(0, ans, S, subset);

	return ans;
}

int main()
{
	int n[] = {1, 3, 2};
	vector<int> S(n, n + sizeof(n) / sizeof(int));
	subsets(S);

	system("pause");
	return 0;
}